<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商城后台管理—-个人中心</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--引入Bootstrap-->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!--自定义工具-->
    <script src="js/HttpUtil.js"></script>
    <!--导入vue 包-->
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>


    <style>
        a:hover {
            color: #cc3333;
            text-decoration: none;
        }

        a {
            color: black;
            cursor: pointer;
        }
    </style>
</head>

<body>

<div class="container-fluid" style="margin-top: 1%">
    <!-- 头信息 -->
    <header>
        <div class="col-xs-offset-1">
            <img src="../view-api/images/vip.logo.png">
        </div>
        <hr>
        <div class="row" style="background-color: #A4D3EE">
            <div class="col-xs-2 col-lg-offset-1">
                <h4>GitBug 商城</h4>
            </div>
        </div>
    </header>


    <div class="row">
        <div class="col-xs-1 col-lg-offset-1" style="background-color:#F7F7F7; height: 800px; position: absolute">
            <h5 style="padding:50% 0 10% 20%"><a href="home_admin.html">概况</a></h5>
            <h5 style="padding:10% 0 10% 20%"><a href="goods-manage.html">商品管理</a></h5>
            <h5 style="padding:10% 0 10% 20%"><a href="orderItems_admin.html">订单管理</a></h5>
            <h5 style="padding:10% 0 10% 20%"><a href="data_analyse.html">数据中心</a></h5>
        </div>

    </div>

    <div id="home_vue">
        <div class="col-xs-6 col-xs-offset-2 " style="margin-top: 3%; background-color: honeydew">
            <div class="row">
                <div style="margin-top: 5%">
                    <span style="font-size: larger; ">&nbsp;&nbsp;实时统计</span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <span style="font-size: small; color: grey">统计时间：{{new Date()|formatDate}}</span>
                </div>

                <div class="col-xs-3 col-lg-offset-1" style="margin-top: 5%">
                    <h4>{{orderNum}}</h4>
                    <h5 style="color: grey">付款订单</h5>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style=" margin-top: 5%">
                    <h4>{{totalPrice|showPrice}}</h4>
                    <h5 style="color: grey">付款金额（元）</h5>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style=" margin-top: 5%">
                    <h4>{{unitPrice|showPrice}}</h4>
                    <h5 style="color: grey">客单价</h5>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-3 col-lg-offset-1" style=" margin-top: 5%">
                    <h4>{{totalGoodsNumber}}</h4>
                    <h5 style="color: grey">商品总数</h5>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style="margin-top: 5%">
                    <h4>{{onSaleGoodsNumber}}</h4>
                    <h5 style="color: grey">在售商品数</h5>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style="margin-top: 5%">
                    <h4>{{goodsViews}}</h4>
                    <h5 style="color: grey">浏览量（今日）</h5>
                </div>
            </div>
        </div>

        <div class="col-xs-6 col-xs-offset-2 " style="margin-top: 3%; background-color: honeydew">
            <div class="row">
                <div style="margin-top: 5%">
                    <span style="font-size: larger; ">&nbsp;&nbsp;待办事物</span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <span style="font-size: small; color: grey">统计时间：{{new Date()|formatDate}}</span>
                </div>

                <div class="col-xs-3 col-lg-offset-1" style=" margin-top: 5%">
                    <h4>{{waitingOrder}}</h4>
                    <h5 style="color: grey">待处理订单</h5><a href="orderItems_admin.html" style="color: #0b76ac">处理</a>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style="margin-top: 5%">
                    <h4>{{underStockGoodsNumber}}</h4>
                    <h5 style="color: grey">库存不足商品</h5><a href="goods-manage.html" style="color: #0b76ac">处理</a>
                </div>
                <div class="col-xs-3 col-lg-offset-1" style=" margin-top: 5%">
                    <h4>{{totalGoodsNumber-onSaleGoodsNumber}}</h4>
                    <h5 style="color: grey">未上架商品</h5><a href="goods-manage.html?status=0" style="color: #0b76ac">处理</a>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 页脚信息 -->
<div class="container-fluid" style="background-color: ghostwhite; margin-top: 5%; ">
    <div class="row" style="margin-top: 2%;margin-bottom: 5%">
        <div class="col-xs-1 col-xs-offset-2">
            <p style="">视频中心</p>
            <a>
                <div style="padding-top: 10%">新闻发布会</div>
            </a>
            <a>
                <div style="padding-top: 5%">发展历程</div>
            </a>
            <a>
                <div style="padding-top: 5%">直播</div>
            </a>
            <a>
                <div style="padding-top: 5%">员工视频</div>
            </a>
        </div>
        <div class="col-xs-1 ">
            <p style="">发现</p>
            <a>
                <div style="padding-top: 10%">成功故事</div>
            </a>
            <a>
                <div style="padding-top: 5%">公司年报</div>
            </a>
            <a>
                <div style="padding-top: 5%">管理层信息</div>
            </a>
            <a>
                <div style="padding-top: 5%">媒体图库</div>
            </a>
        </div>
        <div class="col-xs-1 ">
            <p style="">关注我们</p>
            <a>
                <div style="padding-top: 10%">新浪微博</div>
            </a>
            <a>
                <div style="padding-top: 5%">微信公众号</div>
            </a>
            <a>
                <div style="padding-top: 5%">优酷视频</div>
            </a>
            <a>
                <div style="padding-top: 5%">哔哩哔哩</div>
            </a>
        </div>
        <div class="col-xs-1 ">
            <a href="http://localhost:8080/views/view-api/home2.html">商城主页</a>
        </div>
    </div>
</div>

</body>
</html>


<script type="text/javascript">

    let vue = new Vue({
        el: '#home_vue',
        data: {
            orderNum: "",
            totalPrice: "",
            totalGoodsNumber: "",
            onSaleGoodsNumber: "",
            waitingOrder: "",
            underStockGoodsNumber: "",
            unShelveGoodsNumber: "",
            unitPrice: "",
            goodsViews: ""

        },


        filters: {

            //价格
            showPrice(price) {
                if (price !== null) {
                    return '￥' + price.toFixed(2)
                } else {
                    return '￥0.00'
                }

            },
            formatDate(value) {
                if (value != null) {
                    let date = new Date(value);
                    let y = date.getFullYear();
                    let MM = date.getMonth() + 1;
                    MM = MM < 10 ? ('0' + MM) : MM;
                    let d = date.getDate();
                    d = d < 10 ? ('0' + d) : d;
                    let h = date.getHours();
                    h = h < 10 ? ('0' + h) : h;
                    let m = date.getMinutes();
                    m = m < 10 ? ('0' + m) : m;
                    let s = date.getSeconds();
                    s = s < 10 ? ('0' + s) : s;
                    return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
                } else {
                    return null
                }
            }
        },
        methods: {
            initHome: function () {
                let url = "Data/initData"
                let thisObject = this;
                get(url, function (data) {
                    thisObject.orderNum = data.orderNum;
                    thisObject.totalPrice = data.totalPrice;
                    thisObject.totalGoodsNumber = data.totalGoodsNumber;
                    thisObject.waitingOrder = data.waitingOrder
                    thisObject.onSaleGoodsNumber = data.onSaleGoodsNumber
                    thisObject.underStockGoodsNumber = data.underStockGoodsNumber
                    thisObject.goodsViews = data.goodsViews;
                    if (thisObject.totalPrice === null) {
                        thisObject.unitPrice = null;
                    } else {
                        thisObject.unitPrice = thisObject.totalPrice / thisObject.orderNum
                    }
                })
            },


        },

        mounted: function () {
            //页面加载完成，并且vue对象加载完成之后调用
            this.initHome();
        },
    });


    $(function () {
        filterLogin();
    });
    
    
    function filterLogin() {
        if (sessionStorage.id!=36){
            location.href="../view-api/login.html";
            return;
        }
    }
</script>